﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BBB.Valuta
{
    public partial class PrinterSelect : Form
    {
        public PrinterSelect()
        {
            InitializeComponent();
            printerNameComboBox.DataSource = Settings.GetInstance().Printers.ToList();
            printerNameComboBox.DisplayMember = "Name";
            printerNameComboBox.ValueMember = "Location";
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }

        public DialogResult ShowDialog(out bool isPrint, out string s)
        {
            DialogResult result = ShowDialog();
            if (printRadioButton.Checked)
            {
                isPrint = true;
                if (isPrint && printerNameComboBox != null)
                    s = printerNameComboBox.SelectedValue.ToString();
                else
                {
                    s = string.Empty;
                }
            }
            else
            {
                isPrint = false;
                s = fileSaveTextBox.Text;
            }
            return result;
        }

        private void printRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            printerNameComboBox.Visible = printRadioButton.Checked;
            fileSaveTextBox.Visible = !printRadioButton.Checked;
            selectFileButton.Visible = !printRadioButton.Checked;
        }

        private void selectFileButton_Click(object sender, EventArgs e)
        {
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
                fileSaveTextBox.Text = saveFileDialog.FileName;
        }


    }
}
